// 数组
const arr1: number[] = [1, 2, 3];
const arr2: Array<number> = [1, 2, 3];
const arr3: [string, number, boolean] = ['why', 18, true];
const arr4: [{ name: string; age: number }] = [{ name: 'why', age: 18 }];
const arr5: Array<{ name: string; age: number }> = [{ name: 'why', age: 18 }];

interface Person {
  name: string;
  age: number;
}
const arr6: Array<Person> = [{ name: 'why', age: 18 }];

// 函数类型定义 (函数的返回值在函数后面加)
function sum(a: number, b: number): number {
  return a + b;
}

function sum1(a: number, b: number): void {
  console.log(a + b);
}

function sum2(): never {
  throw new Error('error');
}

const sum3: (a: number, b: number) => number = (a, b) => {
  return a + b;
};
